package com.ettractions.kiosk
{
	import com.ettractions.kiosk.commands.InitializeViewCommand;
	import com.ettractions.kiosk.commands.LoadDataCommand;
	import com.ettractions.kiosk.commands.ProcessDataCommand;
	import com.ettractions.kiosk.components.Brochure;
	import com.ettractions.kiosk.components.BrochureAboutView;
	import com.ettractions.kiosk.components.BrochureMapDirectionsView;
	import com.ettractions.kiosk.components.BrochureMedia;
	import com.ettractions.kiosk.components.BrochureSendToMeView;
	import com.ettractions.kiosk.components.CategoryMenu;
	import com.ettractions.kiosk.components.CoverFlowBrochureCarousel;
	import com.ettractions.kiosk.components.ScreenSaver;
	import com.ettractions.kiosk.components.ThumbnailGrid;
	import com.ettractions.kiosk.components.ThumbnailRibbon;
	import com.ettractions.kiosk.events.ImagePreloadServiceEvent;
	import com.ettractions.kiosk.events.KioskDataServiceEvent;
	import com.ettractions.kiosk.mediators.BrochureAboutMediator;
	import com.ettractions.kiosk.mediators.BrochureMapDirectionsMediator;
	import com.ettractions.kiosk.mediators.BrochureMediaMediator;
	import com.ettractions.kiosk.mediators.BrochureMediator;
	import com.ettractions.kiosk.mediators.BrochureSendToMeMediator;
	import com.ettractions.kiosk.mediators.CategoryMenuMediator;
	import com.ettractions.kiosk.mediators.CoverFlowBrochureCarouselMediator;
	import com.ettractions.kiosk.mediators.ScreenSaverMediator;
	import com.ettractions.kiosk.mediators.ThumbnailGridMediator;
	import com.ettractions.kiosk.mediators.ThumbnailRibbonMediator;
	import com.ettractions.kiosk.models.KioskModel;
	import com.ettractions.kiosk.services.ImagePreloadService;
	import com.ettractions.kiosk.services.KioskDataService;
	
	import flash.display.DisplayObjectContainer;
	
	import org.robotlegs.mvcs.Context;

	public class KioskContext extends Context
	{
		public function KioskContext(contextView:DisplayObjectContainer = null, autoStartup:Boolean = true)
		{
			super(contextView, autoStartup);
		}
		
		override public function startup():void
		{
			injector.mapSingleton(KioskModel);
			injector.mapSingleton(KioskDataService);
			injector.mapSingleton(ImagePreloadService);
			
			mediatorMap.mapView(CategoryMenu, CategoryMenuMediator);
			mediatorMap.mapView(ThumbnailGrid, ThumbnailGridMediator);
			mediatorMap.mapView(ThumbnailRibbon, ThumbnailRibbonMediator);
			mediatorMap.mapView(CoverFlowBrochureCarousel, CoverFlowBrochureCarouselMediator);
			mediatorMap.mapView(Brochure, BrochureMediator);
			mediatorMap.mapView(BrochureMedia, BrochureMediaMediator);
			mediatorMap.mapView(BrochureAboutView, BrochureAboutMediator);
			mediatorMap.mapView(BrochureSendToMeView, BrochureSendToMeMediator);
			mediatorMap.mapView(BrochureMapDirectionsView, BrochureMapDirectionsMediator);
			mediatorMap.mapView(ScreenSaver, ScreenSaverMediator);
			
			commandMap.mapEvent(KioskDataServiceEvent.LOAD_KIOSK_DATA, LoadDataCommand);			
			commandMap.mapEvent(KioskDataServiceEvent.KIOSK_DATA_LOADED, ProcessDataCommand);
			commandMap.mapEvent(ImagePreloadServiceEvent.IMAGE_PRELOAD_COMPLETE, InitializeViewCommand);
			
			eventDispatcher.dispatchEvent(new KioskDataServiceEvent(KioskDataServiceEvent.LOAD_KIOSK_DATA));
		}
	}
}